﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using CMN.Models;
using CMN.Models.Interfaces;
using CMN.Entity;
using CMN.Controllers;
using CMN.Controllers.Filters;
using CMN.Common;
using System.Text;
using CMN.UI;
using CMN.Framework;
namespace CMN.Controllers
{
    [UserAuthorize]
    [LoggerFilter()]
    [ExceptionFilter()]
    [ExecutionTimingAttribute()]
    public class TagController : Controller
    {
        [CompressFilter]
        [CacheFilterAttribute]
        public string Index(string tagName, string pageIndex)
        {


            PageHelperEntity pageHelper = new PageHelperEntity();
            Normal_TagsEntity tag = MvcWebCacheManager.GetNormal_Tags(tagName);
            if (tag != null)
            {
                pageHelper.ParentDir = tag.ChannelPath;
                pageHelper.ContentId = tag.Id;
                pageHelper.Url = tag.Url;
                Normal_ChannelEntity channelEntity = MvcWebCacheManager.GetNormal_ChannelByPath(pageHelper.ParentDir);
                if (channelEntity != null)
                {
                    pageHelper.ParentChannel = channelEntity;
                }
               
                //pageHelper.Title = (string.IsNullOrEmpty(tag.SeoTagName) ? tag.TagName : tag.SeoTagName);
                //pageHelper.Description = tag.HtmlInfo;
            }

            pageHelper.ChannelId = 0;
           


           // string.Concat("/tag/", Utils.UrlEncode(tagName));
            pageHelper.Type = PageType.OtherPage;
            pageHelper.OtherTypeName = "Tags";
            
            if (string.IsNullOrEmpty(pageIndex))
                pageHelper.PageIndex = 1;
            else
                pageHelper.PageIndex = Utils.StringToInt(pageIndex, 1);
            BaseTemplateDisplay articleTemplate = new BaseTemplateDisplay(pageHelper);

            string strRetrun = articleTemplate.Display();
            articleTemplate.Dispose(); 

            return strRetrun;


        }



        
    }
}
